package com.eight.securitydemo1.service;//package com.atguigu.securitydemo1.service;
//
//import com.atguigu.securitydemo1.entity.Test;
//import com.atguigu.securitydemo1.mapper.UserMapper;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.GrantedAuthority;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.List;
////需要自定义逻辑的时候实现UserDetailsService接口即可
//@Service("myUserDetail")
//public class MyUserDetailService implements UserDetailsService {
//    //这是权限集合
//    List<GrantedAuthority> list=new ArrayList<>();
//    //用于查询数据库
//    @Autowired
//    private UserMapper userMapper;
//    @Override
//    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
//        //先查询
//        QueryWrapper<Test> wrapper=new QueryWrapper<>();
//        wrapper.eq("username",s);
//        Test test = userMapper.selectOne(wrapper);
//        System.out.println("执行查询逻辑");
//        String username=test.getUsername();
//        String password=test.getPassword();
//        //注意三个参数
//        return new User(username,new BCryptPasswordEncoder().encode(password),list);
//    }
//}
